package com.mybatis;

import com.mybatis.dao.EmployeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class EmployeeService {

	@Autowired
	EmployeeMapper employeeMapper;
	public List<Employee> getEmps() {
		List<Employee> emps = employeeMapper.getEmps();
		return emps;
	}

	@Transactional
	public int addOne(Employee employee) {
		int add = employeeMapper.add(employee);
		System.out.println(employee);
		int ed = 1/0;//事务测试回滚
		return add;
	}
}
